<template>
    <div class="hotAlbum">
        <h2 class="title">最新专辑</h2>
        <div class="info">
            <router-link to="/albums"  v-for="(a, k) in album" :key="k">
              <div class="albumBox">
                  <div class="pic">
                      <img :src="a.pic" alt="">
                      <div class="bg"><img src="../assets/play.png" alt=""></div>
                  </div>
                  <div class="intro">
                      <p class="songName">{{a.title}}</p>
                      <p class="singerName" v-for="(n,i) in a.artist" :key="i" v-show="i<1">{{n.name}}</p>
                  </div>
              </div>
            </router-link>
        </div>
    </div>
</template>

<script>
export default {
  data() {
    return {
      album: ''
    };
  },
  beforeRouteEnter(to, from, next) {
    next((vm) => {
      vm.getAlbum();
    });
  },
  methods: {
    getAlbum(){
        var url = `https://music.taihe.com/v1/album/list?sign=2ca11dec389a49866ada355b5a3ba454&pageSize=50&appid=16073360&timestamp=1613788244`
        this.axios.get(url).then((res) => {
            this.album = res.data.data.result
        });
    }
  },
};
</script>

<style scoped>
    a {
    text-decoration: none;
    color: #606266;
    }
    .hotAlbum .title{
    width: 80vw;
    margin: 0 auto;
    margin-top: 50px;
    padding-left: 50px;
    font-weight: normal;
    }
    .hotAlbum .info{
    width: 80vw;
    margin: 20px auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    }
    .hotAlbum .info a{
    width: 20%;   
    }
    .hotAlbum a .albumBox{
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    position: relative;
    margin-bottom: 30px;
    }
    .hotAlbum .pic{
    width: 192px;
    height: 192px;
    }
    .hotAlbum .pic .bg{
    position: absolute;
    width: 70%;
    height: 70%;
    z-index: -1;
    top: 0;
    left: 70px;
    transition: all .4s;
    }
    .hotAlbum .pic:hover .bg{
    left: 80px;
    }
    .hotAlbum .pic img{
    width: 100%;
    height: 100%;
    }
    .hotAlbum .intro{
    width: 60%;
    }
    .hotAlbum .intro p {
    width: 90%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin: 10px 0;
    }
    .hotAlbum p.songName:hover{
    color: red;
    }
    .hotAlbum p.singerName{
    color: #909399;
    }
</style>